﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using KPIS.GERP.GBMS.APP;
using KPIS.GERP.GBMS.IBLL;
using KPIS.GERP.GBMS.BLL;
using System.Configuration;
using System.Data;
using Telerik.Web.UI;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Globalization;
using KPIS.GERP.GBMS.MODEL;
using System.Collections;
using System.Threading;
using System.Security;

namespace KPIS.GERP.GBMS.APP_UI
{
    public partial class BGM_ProjectOperationReport : System.Web.UI.Page
    {
        private ManageProject projectBLL = new ManageProject();
        private IProject pjBLL = new Project_BLL();
        private D_BGM_ProjectOperationReport operRepBLL = new D_BGM_ProjectOperationReport();
        private D_BGM_ProjectOperation operBLL = new D_BGM_ProjectOperation();
        private ComboBLL combo = new ComboBLL();
        private Common.Main main = new Common.Main();

        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadData();
            }
        }

        private void LoadData()
        {
            lblProjectOperSeq.Text = Request.QueryString["seq"];
            //Nullable<int> nBgmProjOperSeq = main.ConvertNullInt(lblProjectOperSeq.Text);

            gridReport2.DataSource = operRepBLL.GetFull(lblProjectOperSeq.Text, null, "4, 5");
            gridReport2.DataBind();
            gridReport3.DataSource = operRepBLL.GetFull(lblProjectOperSeq.Text, null, "6");
            gridReport3.DataBind();
            gridReport4.DataSource = operRepBLL.GetFull(lblProjectOperSeq.Text, null, "7");
            gridReport4.DataBind();
            gridReport5.DataSource = operRepBLL.GetFull(lblProjectOperSeq.Text, null, "8");
            gridReport5.DataBind();

            //cmdReturn.Enabled = Request.QueryString["status"] == "A";
        }

        protected void cmdReturn_Click(object sender, EventArgs e)
        {
            //if ( || )
            //{
                
            //}
            //else
            //{
            //    main.MessageAlert(Page, "พบข้อผิดพลาดในการคืนเงิน");
            //}

            try
            {
                operBLL.ReturnExpense(lblProjectOperSeq.Text, new SsMng().EmpSeq, "1");
                operBLL.ReturnExpense(lblProjectOperSeq.Text, new SsMng().EmpSeq, "11");
            }
            catch (Exception ex)
            {
                throw ex;
            }

            main.MessageAlert(Page, "คืนเงินกลับสู่โครงการเรียบร้อย");
        }

        protected void ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridFooterItem)
            {
                GridFooterItem footer = (GridFooterItem)e.Item;
                footer["name"].Controls.Add(new LiteralControl("<span style='color: Black; font-weight: bold;'>รวมทั้งหมด :</span> "));
            }
        }
    }
}